@extends('backstage.layout.master')
@section('title', '权限分配')
@section('style')

@stop
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="backstage/home">主页</a>
            </li>
            <li class="active">
                <a href="backstage/roles/list">角色列表</a>
            </li>
            <li>
                权限分配
            </li>
        </ul><!-- .breadcrumb -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        权限分配
                    </h1>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <form class="form-horizontal" role="form" action="backstage/roles/add-permission" method="post"
                              enctype="multipart/form-data">
                            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                            <input type="hidden" name="id" value="{{$id}}">

                            <div class="form-group {{$errors->first('permission_ids[]')!=""?'has-error':''}}">
                                @foreach($permissions as $key=>$permission)
                                    <div class="col-sm-12">

                                        <div class="col-xs-2">
                                            <input type="checkbox" name="permission_ids[]" value="{{$permission['id']}}"
                                                   id="{{$permission['id']}}" @if(in_array($permission['id'],$permission_select_ids)) checked @endif><label
                                                    for="{{$permission['id']}}">{{$permission['display_name']}}</label>------
                                        </div>
                                        <div class="col-xs-10" style="margin-bottom: 20px;">
                                            @foreach($permission['child'] as $permission_child)
                                                <div class="col-xs-12">
                                                    <div class="col-xs-12">
                                                        <input type="checkbox" name="permission_ids[]"
                                                               value="{{$permission_child['id']}}"
                                                               id="{{$permission_child['id']}}" @if(in_array($permission_child['id'],$permission_select_ids)) checked @endif><label
                                                                for="{{$permission_child['id']}}">{{$permission_child['display_name']}}</label>
                                                    </div>
                                                    @foreach($permission_child['child'] as $p)
                                                        <div class="col-xs-4">
                                                            ┗━<input type="checkbox" name="permission_ids[]"
                                                                   value="{{$p['id']}}"
                                                                   id="{{$p['id']}}" @if(in_array($p['id'],$permission_select_ids)) checked @endif><label
                                                                    for="{{$p['id']}}">{{$p['display_name']}}</label>
                                                        </div>
                                                    @endforeach
                                                </div>
                                            @endforeach
                                        </div>

                                    </div>
                                @endforeach
                            </div>

                            <div class="clearfix form-actions">
                                <div class="col-md-offset-5">
                                    <button class="btn btn-info" type="submit">
                                        <i class="icon-ok bigger-110"></i>
                                        保存
                                    </button>
                                    &nbsp; &nbsp; &nbsp;
                                    <button class="btn" type="reset">
                                        <i class="icon-undo bigger-110"></i>
                                        重置
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div><!-- /row -->
                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div>
@stop
@section('script')

@stop